package marionito.domaine;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import marionito.util.Util;

import com.sun.istack.internal.NotNull;


@SuppressWarnings("serial")
@Entity
@Table(name="CASES", schema="MARIONITO")
public class Case implements Serializable{
	@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;

	@NotNull
	private int num;
	 
	@OneToOne
	@JoinColumn(name="JETON_ID")
	private Jeton jeton;
	
	protected Case() {}

	public Case(int num) {
		Util.checkNumCase(num);
		this.num = num;
	}

	public int getId() {
		return id;
	}

	public int getNum() {
		return num;
	}
	
	public Jeton getJeton() {
		return jeton;
	}

	public void setJeton(Jeton jeton) {
		this.jeton = jeton;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (id != other.id)
			return false;
		return true;
	}
	
	
	
	
}
